/*!
 * \file Debug.h
 * \brief Debugging module.
 * \author Nus
 * \date 2008/02/16, 05:22
 */

#ifndef __DEBUG_H__
#define __DEBUG_H__

#include "Types.h"

//! \name Debug macros.
//! \{

//! \brief Log.
#ifdef _NDEBUG
#define LOG(...)
#else
#define LOG(...) LogStr(__VA_ARGS__)
#endif

//! \brief Assert.
#ifdef _NDEBUG
#define ASSERT_C(_cond)
#else
#define ASSERT_C(_cond) AssertEx(_cond, __FILE__, __LINE__, "Condition: %s\n", #_cond)
#endif

//! \brief Assert.
#ifdef _NDEBUG
#define ASSERT_EX(_cond, ...)
#else
#define ASSERT_EX(_cond, ...) AssertEx(_cond, __FILE__, __LINE__, __VA_ARGS__)
#endif

//! \brief Verify.
#ifdef _NDEBUG
#define VERIFY_C(_cond)
#else
#define VERIFY_C(_cond) Verify(_cond, "Verify: %s, %s\n", #_cond, \
                               _cond ? "true" : "false")
#endif

//! \}



//! \name Debug functions.
//! \{

//! \brief Log to console.
extern "C" void LogStr(const s8* format, ...);

//! \brief Assert with logging to console.
extern "C" void AssertEx(s32 cond,
                         const s8* file,
                         u32 line,
                         const s8* format, ...);

//! \brief Verify.
extern "C" void Verify(s32 cond,
                       const s8* format, ...);

//! \}

#endif
